package ru.volgogradetzzz.tween.easing {

	public class Expo {
		public static function easeIn(time:uint, before:Number, change:Number, duration:uint):Number {
			if (time == 0) {
				return before;
			}
			
			return change * Math.pow(2, 10 * (time / duration - 1)) + before;
		}
		
		public static function easeOut(time:uint, before:Number, change:Number, duration:uint):Number {
			if (time >= duration) {
				return before + change;
			}
			
			return change * (-Math.pow(2, -10 * time / duration) + 1) + before;
		}
		
		public static function easeInOut(time:uint, before:Number, change:Number, duration:uint):Number {
			if (time == 0) {
				return before;
			}
			
			if (time >= duration) { 
				return before + change;
			}
			
			var ratio:Number = time / duration * 2;
			
			if (ratio < 1) {
				return change / 2 * Math.pow(2, 10 * (ratio - 1)) + before;
			}
			
			return change / 2 * (-Math.pow(2, -10 * --ratio) + 2) + before;
		}
	}
}
